package com.tom;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Random;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DiceServlet extends HttpServlet {

        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                        throws ServletException, IOException {
                Random r = new Random();
                PrintWriter out = resp.getWriter();
                out.println("<HTML>");
                out.println("<HEAD>");
                out.println("</HEAD>");
                out.println("<BODY>");
                out.println(r.nextInt(6)+1);
                out.println("</BODY>");
                out.println("</HTML>");
                
        }

        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp)
                        throws ServletException, IOException {
                // TODO Auto-generated method stub
                doGet(req, resp);
        }

}